Notes on trait-o-matic front end process:
i.e. how to hack the phenotypes displayed without a terribly good understanding of trait-o-matic

what we see at filip.freelogy.org/results2/samples/[name]:
(this gets automatically rerouted as "filip.freelogy.org/samples2/[name]")

Code Igniter uses a View/Controller model: the view is mainly just html aesthetic and the Controller contains a set of functions accessed as "/controller_name/function/var1/var2...":

views/results2.php

*** Note that even as late as in this views section, some last minute modification/refinement of the data is done: could we do some of our data classification at this stage to avoid reprocessing with each modification???***

controllers/results2.php

Tracing the data back from front end to core:

in controllers/results2.php:

function "samples":
loads view 'results2' with $data = $this->_prep_results($user, TRUE)

V
V

function "_prep_results":
reads results as $data['phenotypes']['database_name'] = $this->_load_output_data('database_name', $job_id, $job_dir)

V
V

function "_load_output_data":
***this is where the data gets sorted (currently by chromosomal place)***

*how to change sort order:
first makes columns from the rows we get in $data, then briefly fixes up the chromosomal numbers, then uses php function "array_multisort" (see http://us2.php.net/manual/en/function.array-multisort.php for documentation of this whole process)

reads data depending on config settings: if, as is currently the case, $config['backend_intermediary'] = 'json' in the file /config/trait-o-maic.php, then

#1:

we get the file info from the 'ariel' table; the line

$file = $this->file->get(array('kind' => "out/{$kind}", 'job' => $job_id), 1);

calls a function from the 'files' model:

V
V

in models/file:
(models are just sub-files in the codeIgniter structure which contain functions, accessed by "$this->Model_Name->function()", used generally to retrieve stored data to be delivered to the frontend)

function "get":
(helpful here to look at the built-in Code Igniter database functions; T-o-M uses "Active Record" commands, see http://codeigniter.com/user_guide/database/active_record.html)

NOTE: default database is 'ariel' (under the 'writer' username), see config/database.php

***This is the point at which the mysql database is initially queried; gets records from 'files' table in ariel; i.e. we will get the mySQL query: "SELECT * FROM 'files' WHERE kind = 'out/$kind' AND job = '$job_id' LIMIT $limit, $offset"

Back to function "_load_output_data"

/\
/\

#2:

Now, we get the data by accessing the json files referenced in the 'files' table of ariel:

$data = array();
$path = $file['path'];
foreach (preg_split('/[\r\n]+/', read_file($path), -1, PREG_SPLIT_NO_EMPTY) as $line)
{
       $data[] = get_object_vars(json_decode($line));
}


END OF FRONT-END PROCESS!!!
----------------------------------------------

Now on to the back-end/core process, i.e. how the JSON files are prepared:























